package AbstractMapper;

public class SortableResult implements Comparable<SortableResult> {
private Integer _score, _score1, _score2; //TODO implement list of scores - to implement voting on an unconstrained voter list.
private Object _Result;//usually an AbstractAnalogy but could be anything
private boolean resolveTies, resolve2Ties = false;

	public SortableResult(Integer score, Object Result)
	{
		_score = score;
		_Result = Result;
	}
	public SortableResult(Integer score, Integer score1, Object Result)
	{
		_score = score;
		_score1 = score1;
		_Result = Result;
		resolveTies = true;
	}
	public SortableResult(Integer score, Integer score1, Integer score2, Object Result)
	{
		_score = score;
		_score1 = score1;
		_score2 = score2;
		_Result = Result;
		resolve2Ties = true;
	}
	public Object getObject()
	{
		return _Result;
	}
	public int compareTo(SortableResult res) {		                   
        
        if (_score > res.getScore())
        {
        	//Log.current.println("this.score = " + _score + " is bigger than " + res.getScore());
        	return -1;
        }
        else if (_score < res.getScore()) 
        {
        	//Log.current.println("this.score = " + _score + " is smaller than " + res.getScore());        	        	
        	return 1;
        }
        else // (_score == res.getScore())
        {
        	if (resolveTies)
        	{
        		if (_score1 > res.getScore1())
        			return -1;
        		else if (_score1 < res.getScore1())
        			return 1;
        		else if (resolve2Ties)
        		{
        			if (_score2 > res.getScore2())
        				return -1;
        			else
        				return 1;
        		}
        		else
        			return 1;
        	}
        	else
        		return 1;

        }
        
	}
	
	public Integer getScore()
	{
		return _score;
	}
	
	public Integer getScore1()
	{
		return _score1;
	}

	public Integer getScore2()
	{
		return _score2;
	}

	@Override
	public String toString()
	{
		return _Result.toString();	
	}

}
